local BlueLogic = require("tencentApi.BlueLogic")
local Define = require("tencentApi.Define")
local PayLogic = require("tencentApi.PayLogic")
local ItemDefine = require("bag.ItemDefine")
local Broadcast = require("broadcast.Broadcast")
local Lang = require("common.Lang")
local QPoint = require("activity.operate.QPoint")
local Banshu = require("common.Banshu")

function CG_BLUE_KT_TOKEN(human, msg)
	 BlueLogic.blueGetToken(human, msg.type)
end

-- 蓝钻开通信息，没办法区分是否开通成功，只要关闭游戏内开通蓝钻面板，都请求刷一下蓝钻信息
function CG_QQ_BLUE_KT_RESULT(human, msg)
   PayLogic.updateTotalVipInfo(human, 1)
end

function CG_QQ_BUY_GOOD(human, m)
    if not Banshu.IS_CHONGZHI then
        Broadcast.sendBroadcast(human, Lang.MOUSE, "充值暂未开放！")
        return
    end
    local price
    local qd 
    if m.itemid == ItemDefine.ITEM_ID_LOTTERY then     
      price = 10
      qd = 10
      local hour = os.date("%H", os.time()) + 0
      local minute = os.date("%M", os.time()) + 0
      if hour > 21 or (hour == 21 and minute >= 58) then
        return Broadcast.sendBroadcast(human, Lang.DOWN, Lang.YUNYING_TIME_IS_PASS)
      end
      local tmp = QPoint.getPersonInfo(human)
      if #tmp >= 100 then
        return Broadcast.sendBroadcast(human, Lang.DOWN, Lang.YUNYING_QPOINT_LIMIT)
      end
    elseif m.itemid == ItemDefine.ITEM_ID_DAILY_GIFT then
      if human.db.lv < 30 then
          return
      end
      if human.db.dailyGiftStatus ~= 0 then
          return
      end
      price = 10
      qd = 10
    elseif m.itemid == ItemDefine.ITEM_ID_GOLD_MONTH_CARD then
      price = 388
      qd = 388
    else
      local common = ItemDefine.getValue(m.itemid, "command")
      if not common or not common[2] or common[1] ~= "yuanbao" then
        return
      end    
      price = common[2]
      qd = common[2]
    end   
    local cf = ItemDefine.getCf(m.itemid)
    local empty = {}  -- 注:保留引用，回调会出问题
    empty.item_id = m.itemid
    empty.item_cnt = cf.cnt    
    empty.price = price
    empty.qd = price
    PayLogic.MakeTransaction(human, Define.DELIVER_ID_SHOP_ITEM, cf.name, cf.name, m.itemid, price,1, empty)
end